package hell.satan.droidbdf.utils;

import java.util.HashMap;

/**
 * ID生成器
 * ID Generator
 *
 * @author Cerberus
 */
@SuppressWarnings("unused")
public class Generator {
    private HashMap<String, Integer> mGroup = new HashMap<>();

    /**
     * 生成ID，各组间的ID互相独立
     * Generate ID, ID between the groups are not related
     *
     * @param group 要生成ID的组名
     *              Group name to generate ID
     * @return 生成的ID。 Generated ID.
     */
    public int generateID(String group) {
        if (!mGroup.containsKey(group)) {
            mGroup.put(group, 0);
        }
        int id = mGroup.get(group);
        mGroup.put(group, id + 1);
        return id;
    }
}
